<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .yanzhengma {
            height: 20px;
            width: 250px;
        }
        
        .bot {
            height: 30px;
            width: 100px;
        }
    </style>
</head>

<body>
    <input type="text" name=yanzhengma class="yanzhengma" disabled="disabled">
    <input type="button" value="发送验证码" class="bot">
    <script>
        var yanzhengma = document.querySelector(".yanzhengma");
        var bot = document.querySelector(".bot");
        bot.addEventListener("click", function() {
            let second = 60;
            yanzhengma.disabled = false;
            bot.disabled = true;

            var a = setInterval(function() {
                if (second == 0) { //if后面还会继续执行
                    yanzhengma.disabled = true;
                    bot.disabled = false;
                    bot.value = "发送验证码";
                    clearInterval(a);

                } else {
                    bot.value = second--;
                }

            }, 1000)
        });
    </script>

</body>

</html>